import { requestClient } from '#/api/request';

/**
 * 预览后端代码
 */
export async function genCodePreviewCodeApi(modelCode: string) {
  return requestClient.get(`/gen/code/previewCode?modelCode=${modelCode}`);
}

/**
 * 生成文件到后端项目
 * @param modelCode
 */
export async function genCodeToProjectApi(modelCode: string) {
  return requestClient.get(`/gen/code/genCodeToProject?modelCode=${modelCode}`);
}

/**
 * 预览前端代码
 */
export async function genCodeFrontEndPreviewCodeApi(pageId: string) {
  return requestClient.get(`/gen/code/previewFrontEndCode?pageId=${pageId}`);
}

/**
 * 生成前端代码到项目
 * @param pageId
 */
export async function genCodeFrontEndToProjectApi(pageId: string) {
  return requestClient.get(
    `/gen/code/genCodeFrontEndToProject?pageId=${pageId}`,
  );
}

/**
 * 生成SQL
 * @param pageId
 */
export async function genCodeFrontEndSqlApi(pageId: string) {
  return requestClient.get(`/gen/code/genSql?pageId=${pageId}`);
}

/**
 * 生成并下载后端代码压缩包
 * @param modelCode 模型编码
 */
export async function downloadBankCodeZipApi(modelCode: string) {
  return requestClient.get<ResponseBlob>(`/gen/code/downloadBankCode`, {
    params: { modelCode },
    responseType: 'blob',
    returnError: true,
  });
}
